<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: DAOFactory.cfc 1195 2007-07-18 05:05:59Z pfarrell $

Notes:
--->
<cfcomponent 
	displayname="DAOFactory" 
	output="false" 
	hint="DAO Factory for MachBlog">

	<!---
	PROPERTIES
	--->
	<cfproperty name="datasource" type="machblog.org.machblog.datasource.Datasource" required="true" />

	<!---
	INITIALIZATION / CONFIGURATION
	--->	
	<cffunction name="init" access="public" output="false" returntype="DAOFactory">
		<cfargument name="datasource" type="machblog.org.machblog.datasource.Datasource" required="true" />
		
		<cfset setDatasource(arguments.datasource) />
		
		<cfreturn this />
	</cffunction>
	
	<cffunction name="getDatasource" access="public" output="false" returntype="machblog.org.machblog.datasource.Datasource">
		<cfreturn variables.datasource />
	</cffunction>
	<cffunction name="setDatasource" access="private" output="false" returntype="void">
		<cfargument name="datasource" type="machblog.org.machblog.datasource.Datasource" required="true" />
		<cfset variables.datasource = arguments.datasource />
	</cffunction>

	<!---
	PUBLIC FUNCTIONS
	--->
	<cffunction name="setAggregatorDAO" access="public" output="false" returntype="void">
		<cfargument name="aggregatorDAO" type="machblog.org.machblog.aggregator.AggregatorDAO" required="true" />
		<cfset variables.aggregatorDAO = arguments.aggregatorDAO />
	</cffunction>
	<cffunction name="getAggregatorDAO" access="public" output="false" returntype="machblog.org.machblog.aggregator.AggregatorDAO">
		<cfset var aggregatorDAO = CreateObject("component", "machblog.org.machblog.aggregator.AggregatorDAO_" 
																& getDatasource().getDbType()).init() />
		<cfreturn aggregatorDAO />
	</cffunction>

	<cffunction name="setCategoryDAO" access="public" output="false" returntype="void">
		<cfargument name="DAO" type="machblog.org.machblog.category.CategoryDAO" required="true" />
		<cfset variables.categoryDAO = arguments.categoryDAO />
	</cffunction>	
	<cffunction name="getCategoryDAO" access="public" output="false" returntype="machblog.org.machblog.category.CategoryDAO">
		<cfset var categoryDAO = CreateObject("component", "machblog.org.machblog.category.CategoryDAO_" 
															& getDatasource().getDbType()).init() />
		<cfreturn categoryDAO />
	</cffunction>

	<cffunction name="setCommentDAO" access="public" output="false" returntype="void">
		<cfargument name="commentDAO" type="machblog.org.machblog.comment.CommentDAO" required="true" />
		<cfset variables.commentDAO = arguments.commentDAO />
	</cffunction>	
	<cffunction name="getCommentDAO" access="public" output="false" returntype="machblog.org.machblog.comment.CommentDAO">
		<cfset var commentDAO = CreateObject("component", "machblog.org.machblog.comment.CommentDAO_" 
															& getDatasource().getDbType()).init() />
		<cfreturn commentDAO />
	</cffunction>

	<cffunction name="setEntryDAO" access="public" output="false" returntype="void">
		<cfargument name="entryDAO" type="machblog.org.machblog.entry.EntryDAO" required="true" />
		<cfset variables.entryDAO = arguments.entryDAO />
	</cffunction>	
	<cffunction name="getEntryDAO" access="public" output="false" returntype="machblog.org.machblog.entry.EntryDAO">
		<cfset var entryDAO = CreateObject("component", "machblog.org.machblog.entry.EntryDAO_" 
															& getDatasource().getDbType()).init() />
		<cfreturn entryDAO />
	</cffunction>

	<cffunction name="setSubscriberDAO" access="public" output="false" returntype="void">
		<cfargument name="subscriberDAO" type="machblog.org.machblog.subscriber.SubscriberDAO" required="true" />
		<cfset variables.subscriberDAO = arguments.subscriberDAO />
	</cffunction>	
	<cffunction name="getSubscriberDAO" access="public" output="false" returntype="machblog.org.machblog.subscriber.SubscriberDAO">
		<cfset var subscriberDAO = createObject("component", "machblog.org.machblog.subscriber.SubscriberDAO_" 
																& getDatasource().getDbType()).init() />
		<cfreturn subscriberDAO />
	</cffunction>

	<cffunction name="setTrackbackDAO" access="public" output="false" returntype="void">
		<cfargument name="trackbackDAO" type="machblog.org.machblog.trackback.TrackbackDAO" required="true" />
		<cfset variables.trackbackDAO = arguments.trackbackDAO />
	</cffunction>	
	<cffunction name="getTrackbackDAO" access="public" output="false" returntype="machblog.org.machblog.trackback.TrackbackDAO">
		<cfset var trackbackDAO = CreateObject("component", "machblog.org.machblog.trackback.TrackbackDAO_" 
															& getDatasource().getDbType()).init() />
		<cfreturn trackbackDAO />
	</cffunction>

	<cffunction name="setUserDAO" access="public" output="false" returntype="void">
		<cfargument name="userDAO" type="machblog.org.machblog.user.UserDAO" required="true" />
		<cfset variables.userDAO = arguments.userDAO />
	</cffunction>	
	<cffunction name="getUserDAO" access="public" output="false" returntype="machblog.org.machblog.user.UserDAO">
		<cfset var userDAO = CreateObject("component", "machblog.org.machblog.user.UserDAO_" 
															& getDatasource().getDbType()).init() />
		<cfreturn userDAO />
	</cffunction>

</cfcomponent>